package com.cy.ppj.service.account.impl;

import com.cy.ppj.comm.constant.CacheConstants;
import com.cy.ppj.dao.mongodb.BankCardBindLogDao;
import com.cy.ppj.dao.mongodb.BankCardInfoDao;
import com.cy.ppj.model.doc.BankCardBindLog;
import com.cy.ppj.model.doc.BankCardInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @description: 银行卡
 * @author: Ocean
 * @create: 2018-08-02 17:16
 **/
@Service
public class BankCardCacheService {

    @Autowired
    private BankCardBindLogDao bankCardBindLogDao;
    @Autowired
    private BankCardInfoDao bankCardInfoDao;

    @Cacheable(value = CacheConstants.CACHE_VALUE_2H, key = "'queryBankCaedInfo-'+#bankCard")
    public BankCardInfo queryBankCaedInfo(String bankCard) {
        return bankCardInfoDao.findByBankCard(bankCard);
    }

    @CacheEvict(value = CacheConstants.CACHE_VALUE_2H, key = "'queryBankCaedInfo-'+#bankCardInfo.bankCard")
    public void insertBankCaedInfo(BankCardInfo bankCardInfo) {
        bankCardInfoDao.insert(bankCardInfo);
    }

    @Cacheable(value = CacheConstants.CACHE_VALUE_2H, key = "'queryBankCardBindLog-'+#bankCard")
    public BankCardBindLog queryBankCardBindLog(String bankCard) {
        return bankCardBindLogDao.findByBankCard(bankCard);
    }

    @CacheEvict(value = CacheConstants.CACHE_VALUE_2H, key = "'queryBankCardBindLog-'+#bankCardBindLog.bankCard")
    public void insertBankCardBindLog(BankCardBindLog bankCardBindLog) {
        bankCardBindLogDao.insert(bankCardBindLog);
    }



}
